<?php
/*
 * Created on Dec 2, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
class CouponDomain
{
	const TYPE_PERECENT 		= 'Percent';
	const TYPE_SAVE_OFF 		= 'SaveOff';
	const TYPE_FREE_SHIPPING 	= 'FreeShipping';
	
	private $id;
	private $code;
	
	private $scope;
	private $scopeID;
	
	private $isBinding;
	
	private $usedLimit;
	private $usedCount;
	
	private $expireTime;
	
	private $type;
	private $offValue;
	
	private $oCouponCustomer;
	
	public function CouponDomain()
	{
		
	}
	
	public function setID($id)
	{
		$this->id = $id;
	}
	
	public function getID()
	{
		return $this->id;
	}
	
	public function setCouponCustomer($oCouponCustomer)
	{
		$this->oCouponCustomer = $oCouponCustomer;
	}
	
	public function getCouponCustomer()
	{
		return $this->oCouponCustomer;
	}
	
	public function setCode($code)
	{
		$this->code = $code;
	}
	
	public function getCode()
	{
		return $this->code;
	}
	
	public function setScope($scope)
	{
		$this->scope = $scope;
	}
	
	public function getScope()
	{
		return $this->scope;
	}
	
	public function setScopeID($scopeID)
	{
		$this->scopeID = $scopeID;
	}
	
	public function getScopeID()
	{
		return $this->scopeID;
	}
	
	public function setIsBinding($isBinding)
	{
		$this->isBinding = $isBinding;
	}
	
	public function getIsBinding()
	{
		return $this->isBinding;
	}
	
	public function setUsedLimit($usedLimit)
	{
		$this->usedLimit = $usedLimit;
	}
	
	public function getUsedLimit()
	{
		return $this->usedLimit;
	}
	
	public function setUsedCount($usedCount)
	{
		$this->usedCount = $usedCount;
	}
	
	public function getUsedCount()
	{
		return $this->usedCount;
	}
	
	public function setExpireTime($expireTime)
	{
		$this->expireTime = $expireTime;
	}
	
	public function getExpireTime()
	{
		return $this->expireTime;
	}

	public function setType($type)
	{
		$this->type = $type;
	}
	
	public function getType()
	{
		return $this->type;
	}
	
	public function setOffValue($offValue)
	{
		$this->offValue = $offValue;
	}
	
	public function getOffValue()
	{
		return $this->offValue;
	}
	
	public function isExpire()
	{
		if(empty($this->expireTime) || $this->expireTime == '0000-00-00 00:00:00'){
			if($this->getUsedLimit() == 0){
				return false;
			}else if($this->getUsedLimit() <= $this->getUsedCount()){
				return true;
			}else{
				return false;
			}
		}else{
			$result = strtotime(date("Y-m-d H:i:s")) - strtotime($this->getExpireTime());
			
			if($result < 0){
				if($this->getUsedLimit() == 0){
					return false;
				}else if($this->getUsedLimit() <= $this->getUsedCount()){
					return true;
				}else{
					return false;
				}
			}else{
			 	return true;
			}
		}
	}
	
	public function isPercent()
	{
		if($this->type == CouponDomain::TYPE_PERECENT){
			return true;
		}else
			return false;
	}
	
	public function isSaveOff()
	{
		if($this->type == CouponDomain::TYPE_SAVE_OFF){
			return true;
		}else
			return false;
	}
	
	public function isFreeShipping()
	{
		if($this->type == CouponDomain::TYPE_FREE_SHIPPING){
			return true;
		}else
			return false;
	}
}
?>
